package com.cheyunkeji.er.view.evaluate;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.utils.StringUtils;
import com.cheyunkeji.er.view.AbsDialog;


/**
 * Created by Michael on 2017/3/30 14:24.
 */
public class CameraSelectDialog extends AbsDialog implements View.OnClickListener {

    private static final String TAG = CameraSelectDialog.class.getSimpleName() ;
    private Context context;
    private TextView title;
//    private ImageView ivDisplay, ivIconDelete;
    private RelativeLayout tvDpCamera;
    private RelativeLayout tvSystemCamera;
    private RelativeLayout tvGallery;
    private TextView stvCancel;
    private String titleDesc = null;

    private int displayImgResId = 0 ;

    /**
     *是否点击则取消，默认为true
     */
    private boolean clickCancelable = true ;

    private MultiClickActionListener listener;


    public CameraSelectDialog(Context context, String titleDesc, MultiClickActionListener listener, int displayImgResId ) {
        super(context, R.style.dialog_style_dim_3);
        this.context = context;
        this.titleDesc = titleDesc;
        this.listener = listener;
        this.displayImgResId = displayImgResId ;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.er_car_camera_select_dialog);
        findViews();
        setListener();
        initView();

    }

    private void initView() {
        if(titleDesc != null) title.setText(titleDesc);
//        if(displayImgResId != 0) ivDisplay.setImageResource(displayImgResId);
    }

    private void findViews() {
        init();
        title = (TextView) findViewById(R.id.dialog_title);
        tvDpCamera = (RelativeLayout) findViewById(R.id.tv_dp_camera);
        tvSystemCamera = (RelativeLayout) findViewById(R.id.tv_system_camera);
        tvGallery = (RelativeLayout) findViewById(R.id.tv_gallery);
        stvCancel = (TextView) findViewById(R.id.tv_cancel);

    }

    private void setListener() {
//        ivIconDelete.setOnClickListener(this);
        tvDpCamera.setOnClickListener(this);
        tvSystemCamera.setOnClickListener(this);
        tvGallery.setOnClickListener(this);
        stvCancel.setOnClickListener(this);
    }

    public void setTitle(String titleDesc){
        if(!StringUtils.isEmpty(titleDesc))
        this.titleDesc = titleDesc ;
        initView();
    }


    @Override
    public void onClick(View v) {

        if(clickCancelable) dismiss();

        switch (v.getId()) {
//            case R.id.iv_delete:
//                listener.onDelete();
//                break;
            case R.id.tv_dp_camera:
                listener.onCustomizeCameraSelected();
                break;
            case R.id.tv_system_camera:
                listener.onSystemCameraSelected();
                break;
            case R.id.tv_gallery :
                listener.onGallerySelected();
                break ;

            default:
                break;
        }
    }

    /**
     * 删除、挡牌相机、系统相机按钮点击回调接口
     */
    public interface MultiClickActionListener {

//         void onDelete();

         void onCustomizeCameraSelected();

         void onSystemCameraSelected();

        void onGallerySelected();
    }
}
